package cn.edu.usst.cs.goldfish.booking.meetingroom.service.impl;


import cn.edu.usst.cs.goldfish.booking.meetingroom.model.Recharge;
import cn.edu.usst.cs.goldfish.booking.meetingroom.model.SysUser;
import cn.edu.usst.cs.goldfish.booking.meetingroom.mybatis.UserMapper;
import cn.edu.usst.cs.goldfish.booking.meetingroom.service.ChargeService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ChargeServiceImpl implements ChargeService {
    private final BaseMapper<Recharge> chargeMapper;
    private final UserMapper userMapper;

    public ChargeServiceImpl(BaseMapper<Recharge> chargeMapper, UserMapper userMapper) {
        this.chargeMapper = chargeMapper;
        this.userMapper = userMapper;
    }

    @Override
    public void recordCharge(Recharge charge) {


        chargeMapper.insert(charge);
//        Long userId = charge.getUserId();
//        if (userId == null)
//            return;
//        SysUser user=userMapper.selectOne(
//                new QueryWrapper<SysUser>().eq("id", userId)
//        );
//        if(user==null)
//            return;

    }

    @Override
    public List<Recharge> getHistory(Long realId) {
        return chargeMapper.selectList(
                new QueryWrapper<Recharge>().eq("user_id", realId)
        );
    }
}